package com.qijian.production.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qijian.production.domain.ScWorkOrder;
import com.qijian.production.domain.ScWorkOrderDetail;
import com.qijian.production.domain.query.ScWorkOrderDetailQuery;
import com.qijian.production.domain.query.ScWorkOrderQuery;
import com.qijian.production.domain.vo.ScWorkOrderDetailVo;
import com.qijian.production.domain.vo.ScWorkOrderVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 生产计划单Mapper接口
 *
 * @author zhangcheng
 * @date 2025-03-25
 */
public interface ScWorkOrderMapper extends BaseMapper<ScWorkOrder> {

    @Select("select count(0) from sc_work_order WHERE create_time >= CURRENT_DATE ")
    int countCurrentDateWithDel();


    Page<ScWorkOrderVo> pageVo(Page<ScWorkOrder> page,@Param(Constants.WRAPPER) QueryWrapper<ScWorkOrderQuery> query);

    Page<ScWorkOrderVo> pageDetailVo(Page<ScWorkOrder> page, @Param(Constants.WRAPPER) QueryWrapper<ScWorkOrderQuery> query);

    Page<ScWorkOrderDetailVo> listDetail(Page<ScWorkOrderDetail> page, @Param(Constants.WRAPPER) QueryWrapper<ScWorkOrderDetailQuery> query);

    ScWorkOrderVo getOrderDetailByQuery(@Param(Constants.WRAPPER) QueryWrapper<ScWorkOrderQuery> query);

    List<ScWorkOrderVo> geChildWorkOrder(@Param("workOrderId") Long workOrderId);

    List<ScWorkOrderVo> getNeedItem(@Param("workOrderId") Long workOrderId, @Param("workOrderDetailId") Long workOrderDetailId);

    ScWorkOrderVo getMaxSortData(@Param("workOrderId") Long workOrderId);

    ScWorkOrderDetailVo selectWorkOrderDetailByDetailId(Long detailId);

    ScWorkOrderVo getPassRateReportHead(@Param(Constants.WRAPPER) QueryWrapper<ScWorkOrderQuery> query);

    Page<ScWorkOrderVo> getPassRateReportBody(Page<ScWorkOrder> page, @Param(Constants.WRAPPER) QueryWrapper<ScWorkOrderQuery> query);
}
